package jgjc.controller;

import com.alibaba.fastjson.JSONObject;
import com.jgjc.entity.CommonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@Slf4j
@RestController
public class UserServiceController {

    @Resource
    private RestTemplate restTemplate;

    //    @Value("${service-url.nacos-user-service}")
    private String serviceUrl = "http://Basic-Data-Management";

    @PostMapping(value = "/consumer/user/login")
    public CommonResult login(@RequestBody JSONObject jsonParam) {
        CommonResult commonResult = restTemplate.postForObject(serviceUrl + "/user/login", jsonParam, CommonResult.class);
        return commonResult;
    }

    @GetMapping(value = "/consumer/user/check")
    public CommonResult check() {
        CommonResult commonResult = restTemplate.getForObject(serviceUrl + "/user/check", CommonResult.class);
        return commonResult;
    }
}
